<template>
  <div>
    <el-button type="primary" size="medium" plain @click="eject"
      >添加</el-button
    >
    <v-list @edit='edit'  :list='list' @init='init'></v-list>
    <v-dialog :eject="info" @close="close" @init='init' @update='init' :list='list' ref='form'></v-dialog>
  </div>
</template>

<script>
import vList from "./components/list";
import vDialog from "./components/dialog";
import {reqmenulist} from '../../request/api'
export default {
  components: {
    vList,
    vDialog,
  },
  data() {
    return {
      info: {
        isshow: false,
        isadd:false
      },
      list:[]
    };
  },
  created() {},
  mounted() {
   this.init();
  },
  methods: {
    eject() {
      this.info.isshow = true;
      this.info.isadd = true
    },
    close() {
      this.info.isshow = false;
    },
    edit(id){
      this.info.isshow = true;
      this.info.isadd = false;
      this.$refs.form.getone(id)
    },
    init(){
       reqmenulist({istree:true}).then(res=>{
         console.log(res);
         this.list = res.data.list ? res.data.list :[]
       })
    },
  },
};
</script>

<style scoped >
.el-button {
  margin-bottom: 20px;
}
</style>
